
 
 F u n c t i o n :   f o c u s ( d o m E l e m e n t O r C S S S e l e c t o r ,   f u n c t i o n C a l l b a c k ( d o m E l e m e n t )   ) 
 
 
 
 D e s c r i p t i o n :   F o r c e s   p r o g r o m m a t i c   f o c u s   t o   a n y   r e n d e r e d   e l e m e n t   w i t h i n   t h e   b o d y . 
 
 
 
 R e t u r n s :   d o m E l e m e n t ,   o r   $ A   o b j e c t   i f   c h a i n e d . 
 
 
 
 N o t e :   T h i s   m e t h o d   m o v e s   p r o g r a m m a t i c   f o c u s ,   a n d   d o e s   n o t   e x p l i c i t l y   s e t   o r   t r i g g e r   a n y   a t t a c h e d   f o c u s   h a n d l e r s ,   t h o u g h   a n y   o n F o c u s   h a n d l e r s   w i l l   b e   t r i g g e r e d   i f   a t t a c h e d .   T h e   o p t i o n a l   c a l l b a c k   f u n c t i o n   c a n   b e   u s e d   t o   p e r f o r m   a d d i t i o n a l   a c t i o n s   a f t e r   f o c u s   i s   m o v e d .   W h e n   a   C S S   s e l e c t o r   i s   p a s s e d   a s   t h e   f i r s t   p a r a m e t e r ,   f o c u s   w i l l   b e   s e t   t o   t h e   f i r s t   e l e m e n t   t h a t   m a t c h e s   t h e   q u e r y . 
 
 
 
 E x a m p l e : 
 
 
 
 / /   M o v e   f o c u s   t o   a   D O M   e l e m e n t 
 
 $ A . f o c u s ( d o m E l e m e n t ) ; 
 
 
 
 / /   M o v e   f o c u s   t o   a   D O M   e l e m e n t   u s i n g   a   C S S   s e l e c t o r 
 
 $ A . f o c u s ( " h 1 " ) ; 
 
 
 
 / /   M o v e   f o c u s   t o   a   D O M   e l e m e n t   u s i n g   a   C S S   s e l e c t o r   t h e n   e x e c u t e   a   c a l l b a c k 
 
 $ A . f o c u s ( " h 1 " ,   f u n c t i o n ( d o m E l e m e n t )   { 
 
     / /   D o   s o m e t h i n g   w i t h   d o m E l e m e n t 
 
 } ) ; 
 
 
 
 / /   O r   t h e   s a m e   u s i n g   c h a i n i n g 
 
 
 
 / /   M o v e   f o c u s   t o   t h e   f i r s t   h e a d i n g   e l e m e n t   o n   t h e   p a g e 
 
 v a r   m y C h a i n   =   $ A ( " h 1 " ) . f o c u s ( ) ; 
 
 
 
 / /   M o v e   f o c u s   t o   t h e   f i r s t   h e a d i n g   e l e m e n t   o n   t h e   p a g e   t h e n   e x e c u t e   a   c a l l b a c k 
 
 v a r   m y C h a i n   =   $ A ( " h 1 " ) . f o c u s ( f u n c t i o n ( d o m E l e m e n t )   { 
 
     / /   D o   s o m e t h i n g   w i t h   d o m E l e m e n t 
 
 } ) ; 
 
 
 
 / /   T o   r e t u r n   t h e   m o d i f i e d   o b j e c t   w i t h i n   a   c h a i n ,   u s e   t h e   " r e t u r n ( ) "   m e t h o d . 
 
 
 
 v a r   d o m E l e m e n t   =   m y C h a i n . r e t u r n ( ) ; 
 
 